package com.tensai.study.java.supper.branch;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

@Slf4j
public class Lambda {

    private static final Map<String, Consumer<String>> FUNC_MAP = new ConcurrentHashMap<>();
    private static final String MAN = "man";
    private static final String WOMAN = "woman";
    static {
        FUNC_MAP.put(MAN,person -> log.info(person + "应该去男厕所"));
        FUNC_MAP.put(WOMAN,person -> log.info(person + "应该去女厕所"));
    }
    @Data
    static class Person{
        private String gender;
        private String name;
    }
    public static void main(String[] args) {
        Person p = new Person();
        p.setGender(MAN);
        p.setName("张三");
        Person p2 = new Person();
        p2.setGender(WOMAN);
        p2.setName("张三他老婆");

        FUNC_MAP.get(p.getGender()).accept(p.name);
        FUNC_MAP.get(p2.getGender()).accept(p2.name);

    }
}
